'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const Loading = app.model.define('loading', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    carno: { type: STRING(30), comment: '车牌号' },
    checkno: { type: STRING(30), comment: '核放单号' },
    WareHouseBillCode: { type: STRING(30), comment: '报关申请单号', field: 'WareHouseBillCode' },
    loadType: { type: STRING(1), comment: '装/卸货类型 I：装货 E：卸货', field: 'loadType' },
    loadTime: { type: DATE, comment: '装卸货时间', field: 'loadTime' },
    store_id: { type: INTEGER, comment: '仓库' },
    corp_id: { type: INTEGER, comment: '仓库使用公司' },
    owner: { type: STRING(30), comment: '创建者' },
    swner: { type: STRING(30), comment: '审核者' },
    sdate: DATE,
    description: STRING(200),
    status: STRING(10),
    created_at: DATE,
    updated_at: DATE,
  });

  Loading.associate = function() {
    app.model.Wms.Business.Loading.belongsTo(app.model.Wms.Basic.Store, { foreignKey: 'store_id' });
    app.model.Wms.Business.Loading.belongsTo(app.model.Wms.Basic.Corp, { foreignKey: 'corp_id' });
  };

  return Loading;
};
